<?php
/**
 * GioCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@ninhgio.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2010 Gio CMS (http://www.ninhgio.com)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 */

$this->headScript('js/ckeditor/ckeditor.js')
	 ->headScript('js/gio/util.js');

$this->headTitle($this->TRANSLATOR->translator('article_edit_page_title') . ' - ' . $this->TRANSLATOR->translator('common_admin_title', 'core'));
?>
<form action="<?php echo $this->url('news_article_edit', $this->articleData); ?>" method="post" id="gNewsArticleEdit">
	<div class="fl col w7">
		<div class="content">
			<div class="box header mb0">
				<div class="head"><div></div></div>
				<h2 class="g_a_breadcump">
					<a class="fl" href="<?php echo $this->url('core_dashboard_index'); ?>"><?php echo $this->TRANSLATOR->translator('dashboard_breadcump', 'core'); ?></a>
					<small class="icon arrow_right" style="display: block;"></small>
					<a class="fl" href="<?php echo $this->url('news_article_list'); ?>"><?php echo $this->TRANSLATOR->translator('news_breadcump'); ?></a>
					<small class="icon arrow_right" style="display: block;"></small>
					<a class="fl" href="javascript: void(0);"><?php echo $this->TRANSLATOR->translator('article_add_breadcump'); ?></a>
					<div class="clear"></div>
				</h2>
			</div>
		</div>
		<div class="content">
			<div class="desc">
				<div class="body">
					<!--  -->
					<h4 class="g_a_h4 fl"><?php echo $this->TRANSLATOR->translator('article_add_guide'); ?></h4>
					<div class="fr">
						<?php if ($this->ACL->isAllowed('add', 'article')) : ?>
						<a class="fl g_a_tip form_submit g_a_submit_button mr5" href="javascript: void(0);" title="<?php echo $this->STRING->escape($this->TRANSLATOR->translator('article_button_save_title')); ?>"></a>
						<?php endif; ?>
						<a class="fl g_a_tip g_a_cancel_button mr5" href="javascript: history.go(-1);" title="<?php echo $this->STRING->escape($this->TRANSLATOR->translator('common_back_button', 'core')); ?>"></a>
						<?php if ($this->ACL->isAllowed('list', 'article')) : ?>
						<a class="fl g_a_tip" href="<?php echo $this->url('news_article_list'); ?>" title="<?php echo $this->STRING->escape($this->TRANSLATOR->translator('article_list_title')); ?>">
							<img src="<?php echo $this->APP_RESOURCE_SERVER; ?>/templates/<?php echo $this->APP_TEMPLATE; ?>/skins/<?php echo $this->APP_SKIN; ?>/images/news_article_list_icon.png" style="padding: 0 5px 0 0;" />
						</a>
						<?php endif; ?>
					</div>
					<div class="g_a_line"></div>
					<p>
						<input type="hidden" id="module_id" value="news" />
						<label for="simple_input"><?php echo $this->TRANSLATOR->translator('article_language'); ?></label>
						<?php echo Modules_Core_Services_Language::languageSelect(array(
																				'name' => 'article[language]', 
																				'id' => 'languageSelector', 
																				'selected' => $this->articleData['language'])); ?>
						<?php if (isset($this->errorMessages) && isset($this->errorMessages['language'])) : ?>
						<span class="g_a_error"><?php echo $this->TRANSLATOR->translator($this->errorMessages['language']); ?></span>
						<?php endif; ?>						
						<br>
					</p>
					<p class="small">&nbsp;</p>
					<p>
						<label for="simple_input"><?php echo $this->TRANSLATOR->translator('article_source_item'); ?></label>
						<div class="g_a_translatable">
							<?php echo Modules_News_Services_Article::translatableArticle(array(
																							'name' => 'article[source_item]', 
																							'id' => 'article_source_item',
																							'selected' => (null == $this->sourceArticle) ? null : $this->sourceArticle['article_id'],
																							'disabled' => (null == $this->sourceArticle) ? null : $this->sourceArticle['article_id']), $this->articleData['language']); ?>
							</div>					
						<br>
					</p>
					<p class="small">&nbsp;</p>
					<p>
						<label for="simple_input"><?php echo $this->TRANSLATOR->translator('article_title'); ?></label>
						<input title="<?php echo $this->STRING->escape($this->TRANSLATOR->translator('article_title_description')); ?>" type="text" class="text w_30 g_a_tip_right" name="article[title]" id="title" value="<?php if (isset($this->articleData['title'])) : ?><?php echo $this->articleData['title']; ?><?php endif; ?>" />
						<?php if (isset($this->errorMessages) && isset($this->errorMessages['title'])) : ?>
						<span class="g_a_error"><?php echo $this->TRANSLATOR->translator($this->errorMessages['title']); ?></span>
						<?php endif; ?>
						<br>
					</p>
					<p class="small">&nbsp;</p>
					<p>
						<label for="simple_input"><?php echo $this->TRANSLATOR->translator('article_slug'); ?></label>
						<input title="<?php echo $this->STRING->escape($this->TRANSLATOR->translator('article_slug_description')); ?>" type="text" class="text w_30 g_a_tip_right" name="article[slug]" id="slug" value="<?php if (isset($this->articleData['slug'])) : ?><?php echo $this->articleData['slug']; ?><?php endif; ?>" />
						<?php if (isset($this->errorMessages) && isset($this->errorMessages['slug'])) : ?>
						<span class="g_a_error"><?php echo $this->TRANSLATOR->translator($this->errorMessages['slug']); ?></span>
						<?php endif; ?>
						<br>
					</p>
					<p class="small">&nbsp;</p>
					<p>
						<label for="simple_input"><?php echo $this->TRANSLATOR->translator('article_description'); ?></label>
						<textarea name="article[description]" id="description" class="g_a_ui_editor" style="width: 98%; height: 200px"><?php if (isset($this->articleData['description'])) : ?><?php echo $this->articleData['description']; ?><?php endif; ?></textarea>
						<?php if (isset($this->errorMessages) && isset($this->errorMessages['description'])) : ?>
						<span class="g_a_error"><?php echo $this->TRANSLATOR->translator($this->errorMessages['description']); ?></span>
						<?php endif; ?>
						<br>
					</p>
					<p class="small">&nbsp;</p>
					<p>
						<label for="simple_input"><?php echo $this->TRANSLATOR->translator('article_content'); ?></label>
						<textarea name="article[content]" id="content" class="g_a_ui_editor"><?php if (isset($this->articleData['content'])) : ?><?php echo $this->articleData['content']; ?><?php endif; ?></textarea>
						<?php if (isset($this->errorMessages) && isset($this->errorMessages['content'])) : ?>
						<span class="g_a_error"><?php echo $this->TRANSLATOR->translator($this->errorMessages['content']); ?></span>
						<?php endif; ?>
						<br>
					</p>
					<p class="small">&nbsp;</p>
					<p>
						<label for="simple_input"><?php echo $this->TRANSLATOR->translator('article_status'); ?></label>
						<select class="g_a_tip_right" id="status" name="article[status]" title="<?php echo $this->STRING->escape($this->TRANSLATOR->translator('article_status_description')); ?>">
							<option value="inactive"<?php if (isset($this->articleData) && $this->articleData['status'] == 'inactive') : ?> selected="selected"<?php endif; ?>><?php echo $this->TRANSLATOR->translator('article_status_inactive'); ?></option>
							<option value="active"<?php if (isset($this->articleData) && $this->articleData['status'] == 'active') : ?> selected="selected"<?php endif; ?>><?php echo $this->TRANSLATOR->translator('article_status_active'); ?></option>
							<option value="deleted"<?php if (isset($this->articleData) && $this->articleData['status'] == 'deleted') : ?> selected="selected"<?php endif; ?>><?php echo $this->TRANSLATOR->translator('article_status_deleted'); ?></option>
						</select>
						<br>
					</p>
					<p class="small">&nbsp;</p>
					<!--  -->
					<p class="last buttons_demo">
						<?php if ($this->ACL->isAllowed('add', 'article')) : ?>
						<a class="button form_submit green" href="<?php echo $this->url('news_article_add'); ?>"><small class="icon check"></small><span><?php echo $this->TRANSLATOR->translator('common_submit_button', 'core'); ?></span></a>
						<?php endif; ?>
						<a class="button red" href="javascript: history.go(-1);"><small class="icon cross"></small><span><?php echo $this->TRANSLATOR->translator('common_back_button', 'core'); ?></span></a>
					</p>
					<div class="clear"></div>
				</div>
			</div>
			<div class="body_footer">
				<div class="bottom_left"><div class="bottom_right"></div></div>
			</div>
		</div>
	</div>
	<div class="fr col w3">
		<!-- Category -->
		<div class="content">
			<div class="box header mb0">
				<div class="head"><div></div></div>
				<h2><?php echo $this->TRANSLATOR->translator('article_category'); ?></h2>
			</div>
		</div>
		<div class="content">
			<div class="desc">
				<div class="body">
					<p>
						<label for="simple_input"><?php echo $this->TRANSLATOR->translator('article_category_main'); ?></label>
						<div class="g_a_translatable">
							<?php echo Modules_Category_Services_Category::categorySelect(array(
																						'name' => 'article[category_id]', 
																						'id' => 'article_category_id',
																						'selected' => $this->articleData['category_id']), $this->articleData['language'],  'news'); ?>
						</div>					
						<br />
						<p style="font-size: 11px;"><?php echo $this->TRANSLATOR->translator('article_category_select_multi'); ?></p>
						<div style="background: #fff; border: 1px solid #ccc; height: 200px; overflow: auto; width: 100%; font-size: 12px; color: #333;">
							<div class="g_a_translatable">
								<?php echo Modules_Category_Services_Category::categoryCheckbox(array(
																						'name' => 'categories[]', 
																						'id' => 'category_parent_id',
																						'selected' => $this->categories), $this->articleData['language'],  'news'); ?>
							</div>
						</div>
					</p>
				</div>
			</div>
			<div class="body_footer">
				<div class="bottom_left"><div class="bottom_right"></div></div>
			</div>
		</div>
		<!-- / Category -->
	
		<!-- Image -->
		<div class="content" style="margin-top: 10px;">
			<div class="box header mb0">
				<div class="head"><div></div></div>
				<h2><?php echo $this->TRANSLATOR->translator('article_image'); ?></h2>
			</div>
		</div>
		<div class="content">
			<div class="desc">
				<div class="body">
					<div style="border: 1px solid #e5e5e5; height: 223px; line-height: 223px; text-align: center; width: 100%; font-size: 12px; color: #333;" class="g_a_upload_imagetoolbox_thumbnails">
						No image selected										
						<input type="hidden" name="articleImage">
					</div>
				</div>
			</div>
			<div class="body_footer">
				<div class="bottom_left"><div class="bottom_right"></div></div>
			</div>
		</div>
		<!-- / Image -->
		
		<!-- Other settings -->
		<div class="content" style="margin-top: 10px;">
			<div class="box header mb0">
				<div class="head"><div></div></div>
				<h2><?php echo $this->TRANSLATOR->translator('article_other_settings'); ?></h2>
			</div>
		</div>
		<div class="content">
			<div class="desc">
				<div class="body">
					<p>
						<label for="simple_input">
							<input type="checkbox" name="article[article_hot]" value="1"<?php if (isset($this->articleData['article_hot']) && $this->articleData['article_hot'] == 1) : ?> checked="checked"<?php endif; ?> />
							<?php echo $this->TRANSLATOR->translator('article_hot'); ?>
						</label>
					</p>
					<p>
						<label for="simple_input">
							<input type="checkbox" name="article[article_photo]" value="1"<?php if (isset($this->articleData['article_photo']) && $this->articleData['article_photo'] == 1) : ?> checked="checked"<?php endif; ?> />
							<?php echo $this->TRANSLATOR->translator('article_photo'); ?>
						</label>
					</p>
					<p>
						<label for="simple_input">
							<input type="checkbox" name="article[article_video]" value="1"<?php if (isset($this->articleData['article_video']) && $this->articleData['article_video'] == 1) : ?> checked="checked"<?php endif; ?> />
							<?php echo $this->TRANSLATOR->translator('article_video'); ?>
						</label>
					</p>
				</div>
			</div>
			<div class="body_footer">
				<div class="bottom_left"><div class="bottom_right"></div></div>
			</div>
		</div>
		<!-- / Other settings -->
	</div>
</form>
<script type="text/javascript">
$(document).ready(function() {
	<?php if (($string = $this->MESSENGER->printMessages()) != null) : ?>
	Gio.Message.success('<?php echo $string; ?>');
	<?php endif; ?>
	//CKEDITOR.config.contentsCss = '<?php echo $this->APP_STATIC_SERVER; ?>/templates/default/skins/<?php echo $this->APP_SKIN; ?>/style.css';
	CKEDITOR.replace('article[description]', {
		toolbar :
		[
			['Source' , '-', 'Bold', 'Italic', 'Link', '-', 'About']
		],
		width: '98%',
		height: 120,
		language: 'vi'
	})

	CKEDITOR.replace('article[content]', { 
		height: 350,
		width: '98%',
		language: 'vi' 
	});
});
</script>